package ui
{
	import arens.EnumArens;
	
	import feathers.controls.Button;
	import feathers.controls.ScrollContainer;
	import feathers.core.FeathersControl;
	import feathers.core.PopUpManager;
	import feathers.layout.HorizontalLayout;
	import feathers.layout.VerticalLayout;
	
	import managers.LoaderArens;
	import managers.SoundManager;
	
	import starling.events.Event;
	
	import ui.popups.SettingsPopup;
	
	public class MainMenu extends FeathersControl
	{
		private var container:ScrollContainer;
		public function MainMenu()
		{
			super();
		}
		
		protected override function initialize():void{
			super.initialize();
			
			var btnPlay:Button = new Button();
			btnPlay.nameList.add("test");
			btnPlay.label = "Play Game";
			btnPlay.addEventListener(Event.TRIGGERED, onClickBtnNextArea);
			btnPlay.validate();
			//btnNextArena.x=btnNextArena.y=40;
			
			var btnSettings:Button = new Button();
			btnSettings.nameList.add("test");
			btnSettings.label = "Settings";
			btnSettings.addEventListener(Event.TRIGGERED, onClickBtnSettings);
			btnSettings.validate();
			//btnSettings.x=btnSettings.y=80;
			
			var vertLayout:VerticalLayout = new VerticalLayout();
			vertLayout.paddingTop = 40;
			vertLayout.paddingBottom = 40;
			vertLayout.paddingRight = 70;
			vertLayout.paddingLeft = 70;
			vertLayout.gap = 2;
			vertLayout.horizontalAlign = HorizontalLayout.HORIZONTAL_ALIGN_CENTER;
			vertLayout.verticalAlign = VerticalLayout.HORIZONTAL_ALIGN_CENTER;
			
			container = new ScrollContainer();
			container.layout = vertLayout;
			container.addChild(btnPlay);
			container.addChild(btnSettings);
			addChild(container);
			
		}
		
		override protected function draw():void
		{
			// TODO Auto Generated method stub
			super.draw();
			container.validate();
			container.x=(stage.stageWidth-container.width)/2>>1;
			container.y=(stage.stageHeight-container.height)/2>>1;
		}
		
		private function onClickBtnNextArea(e:Event):void{
			SoundManager.getInstance().playSound(SoundManager.BUTTON_CLICK);
			var rClass:RootClass = RootClass.instance;
			rClass.loaderArena = new LoaderArens(EnumArens.PLAY_SCREEN,rClass.arenaLayer);
			
		}
		
		public function onClickBtnSettings(e:Event):void{
			SoundManager.getInstance().playSound(SoundManager.BUTTON_CLICK);
			var popup:SettingsPopup = new SettingsPopup();
			PopUpManager.addPopUp(popup,true,true);
		}
		
		
	}
}